var wetlandParkId = $("#wetlandParkId").val();
var longitude;
var latitude;
var scale;

var overview = $("a[href='#overview']");
var basicInfo = $("a[href='#basicInfo']");
var wetlandType = $("a[href='#wetlandType']");
var naturaFeature = $("a[href='#naturaFeature']");
var wetlandPlant = $("a[href='#wetlandPlant']");
var wetlandAnimal = $("a[href='#wetlandAnimal']");
var ecologicalFun = $("a[href='#ecologicalFun']");
var socioEconomic = $("a[href='#socioEconomic']");
var protectionMainBody = $("a[href='#protectionMainBody']");
var managementOrganization= $("a[href='#managementOrganization']");
var landOwnership = $("a[href='#landOwnership']");
var threatenedStatus = $("a[href='#threatenedStatus']");
var multiMedia = $("a[href='#multiMedia']");

//信息提交成功后在tab页上显示的提示信息
var successHTML = '<i class="green ace-icon fa fa-check-circle bigger-120"></i>';
//信息有误在tab页上显示的提示信息
var warnHTML = '<i class="red ace-icon fa fa-exclamation-circle bigger-120"></i>';

$(function() {
	getInfos();
	$('a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
		var activeTab = $(e.target).attr("href");
		if(activeTab == "#basicInfo"){
			gismap();
		}else if(activeTab == "#wetlandType"){
			typegismap();
		}else if(activeTab == "#socioEconomic"){
			soilgismap();
		}else if(activeTab == "#protectionMainBody"){
			sgismap();
		}
		var preHref = $(e.relatedTarget).attr("href");
		if(preHref == "#overview"){
			overview_add();
		}else if(preHref == "#basicInfo"){
			basicInfo_add();
		}else if(preHref == "#wetlandType"){
			wetlandType_add();
		}else if(preHref == "#naturaFeature"){
			naturaFeature_add();
		}else if(preHref == "#wetlandPlant"){
			wetlandPlant_add_sub();
		}else if(preHref == "#wetlandAnimal"){
			wetlandAnimal_add_sub();
		}else if(preHref == "#ecologicalFun"){
			ecologicalFun_add();
		}else if(preHref == "#socioEconomic"){
			socioEconomic_add();
		}else if(preHref == "#protectionMainBody"){
			protectionMainBody_add();
		}else if(preHref == "#managementOrganization"){
			managementOrganization_add();
		}else if(preHref == "#landOwnership"){
			landOwnership_add();
		}else if(preHref == "#threatenedStatus"){
			threatenedStatus_add();
		}else if(preHref == "#multiMedia"){
			multiMedia_add_sub();
		}
	});
	$('#overview_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#basicInfo_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#wetlandType_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#naturaFeature_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#wetlandAnimal_add_sub').click(function() {
		$(document).scrollTop(0);
	});
	$('#wetlandPlant_add_sub').click(function() {
		$(document).scrollTop(0);
	});
	$('#threatenedStatus_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#socioEconomic_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#protectionMainBody_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#managementOrganization_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#landOwnership_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#ecologicalFun_btn').click(function() {
		$(document).scrollTop(0);
	});
	$('#multiMedia_btn').click(function() {
		$(document).scrollTop(0);
	});

});

function back() {
	history.back();
}

function getInfos(){
	var id =$("#wetlandParkId").val();
	$.ajax({
		url : "findbyid",
		dataType : "json",
		type : "POST",
		data : {id:id},
		async : false,
		error : function(error) {
			console.log(error.responseText);

			$.gritter.add({
				title : '服务器错误',
				text : '对不起，服务器错误，请联系系统管理员！',
				class_name : 'gritter-error'
			});

		},
		success : function(strValue) {
			if (strValue != null) {
				latitude=strValue.wlin_latitude;
				longitude=strValue.wlin_longitude;
				scale=strValue.wlin_scale;
			}
		}
	});
}

